﻿using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using WebAPI.Filters;
using wt.wine.Application.Common.Models;
using wt.wine.Application.ManageConfigtable;
using wt.wine.Application.ManageConfigtable.Command;
using wt.wine.Application.ManageConfigtable.Queries;

namespace WebAPI.Controllers.V1
{
    [ApiController]
    [Route("[controller]/[action]")]
    [LoginFilter]
    public class ManageConfigtableController : ApiControllerBase
    {
        /// <summary>
        /// 【经销商】设置缺酒配置
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("GetconfigtableList")]
        [HttpPost]
        public async Task<Json<PaginatedList<GetconfigtableDTO>>> GetconfigtableList([FromBody] GetconfigtableListQuery query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】修改获取数据
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("GetconfigtableList")]
        [HttpPost]
        public async Task<Json<GetconfigtableDTO>> GetConfigTableById([FromBody] GetConfigTableByIdQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】修改配置
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("GetconfigtableList")]
        [HttpPost]
        public async Task<Json<string>> AddConfig([FromBody] AddConfigTableRepository command)
        {
            return await Mediator.Send(command);
        }


        /// <summary>
        /// 【经销商】修改配置
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("GetconfigtableList")]
        [HttpPost]
        public async Task<Json<string>> EditConfig([FromBody] EditConfigTableRepository command)
        {
            return await Mediator.Send(command);
        }
    }
}
